<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/bootstrap/css/bootstrap-theme.min.css">
<script src="${pageContext.request.contextPath}/js/jquery-1.11.1.js"></script>
<script
	src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.min.js"></script>
<title>用户管理</title>
</head>

<body>
	<nav class="navbar navbar-inverse navbar-fixed-top">
	<div class="container">
		<div class="navbar-header">
			<a class="navbar-brand" href="javascript: void(0)"><strong
				class="h3">用户管理</strong></a>
		</div>

		<div class="collapse navbar-collapse"
			id="bs-example-navbar-collapse-1">
			<ul class="nav navbar-nav">
				<li onclick=""><a href="UserServlet?method=getUserInfoList"
					id="show_infolist"><i class="glyphicon glyphicon-list">&nbsp;</i>显示全部用户</a></li>
			</ul>
			<form name="search" class="navbar-form pull-right" method="post"
				action="UserServlet?method=search">
				&nbsp;&nbsp;&nbsp;&nbsp; <input class="span2" id="info" name="info"
					type="text" style="margin-top: 5px; height: 30px;"
					placeholder="请输入...">
				<button type="submit" class="btn">
					<i class="icon-search"></i>&nbsp;搜索
				</button>
			</form>
		</div>
	</div>
	</nav>
	<div id="userinfolist" class="row-fluid"
		style="margin-top: 100px; margin-left: 150px; margin-right: 150px">
		<c:if test="${! empty infoList}">
			<table class="table table-bordered table-hover">
				<tr>
					<th width="15%">用户名</th>
					<th width="15%">手机</th>
					<th>邮箱</th>
					<th width="30%">操作</th>
				</tr>
				<c:forEach var="info" items="${infoList}">
					<tr>
						<td><span>&nbsp;${info.userName }</span></td>
						<td><span>&nbsp;${info.phoneNumber }</span></td>
						<td><span>&nbsp;${info.email }</span></td>
						<td><input type="button" class="btn btn-primary"
							onclick="javascript:window.location='UserServlet?method=deleteUser&uId=${info.id}'"
							value="删除"> &nbsp;&nbsp; <input type="button"
							class="btn btn-primary"
							onclick="javascript:window.location='UserServlet?method=showUserInfo&uId=${info.id}'"
							value="查看" /></td>
					</tr>
				</c:forEach>
			</table>
		</c:if>
		<c:if test="${! empty user}">
			<table class="table table-bordered table-hover">
				<tr>
					<th width="15%">用户名</th>
					<th width="15%">手机</th>
					<th>邮箱</th>
				</tr>
				<tr>
					<td><span>&nbsp;${user.userName }</span></td>
					<td><span>&nbsp;${user.phoneNumber }</span></td>
					<td><span>&nbsp;${user.email}</span></td>
				</tr>
			</table>
		</c:if>
	</div>
	<div id="fail" class="container"
		style="position: relative; top: 100px; left: 100px">
		<c:if test="${ empty done}">
			<script type="text/javascript">
				document.getElementById("show_infolist").click();
			</script>
		</c:if>
		<c:if test="${! empty fail }">
			<script type="text/javascript">
				alert("删除失败");
			</script>
		</c:if>
		<c:if test="${! empty succeed }">
			<script type="text/javascript">
				alert("删除成功");
			</script>
		</c:if>
		<c:if test="${! empty exist }">
			<script type="text/javascript">
				alert("该用户已有注册信息，不能删除");
			</script>
		</c:if>
	</div>
</body>
</html>